package top.tagao.features_05_time;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author fu-xiao-liu
 * @Date 2022/3/20 21:37
 */
public class DateFormatThreadLocal{
    private  static  final  ThreadLocal<DateFormat> df = new ThreadLocal<DateFormat>(){
        protected  DateFormat initialValue() {
            return new SimpleDateFormat("yyyyMMdd");
        }
    };

    public static Date convert(String source) throws ParseException{
        return df.get().parse(source);
    }

}